<?php
class fs_tree extends CI_Model {

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    public function tree_table_url($table)
    {
        return "site/overview/".$table;
    }

    public function tree_get_record_html($set, $id_field = "ID", $name_field = "NAME", $table_name = "ACTIVE_TABLE")
    {
        $results = array();

        // Records
        foreach ($set->result_array() as $row)
        {
            array_push($results, array("record-item" => "<li><a href='site/tableview/".$row[$table_name]."/" . $row[$id_field] . "'>" . $row[$name_field] . "</a></li>") );
        }

        // Default actios
        array_push($results, array("record-item" => "<li><a class='action' href='site/overview/".$row[$table_name]."'>Overview</a></li>" ));
        array_push($results, array("record-item" => "<li><a class='action' href='site/tableview/".$row[$table_name]."/'>Add new page</a></li>" ));

        return $results;
    }
}